package com.ifp.opengate.boot.validator.service;

import org.springframework.stereotype.Component;

import com.ifp.opengate.boot.bean.ValidateEntity;
import com.ifp.opengate.boot.bean.ValidatorForm;
import com.ifp.opengate.boot.validator.constants.ValidatorConstants;

/**
 * @description: 不能为null，但可以为empty
 * @author: yangquan
 * @create: 2020/3/14
 */
@Component
public class NotNullValidateServiceImpl extends ValidateServiceImpl {

    @Override
    public ValidateEntity validateValue(ValidatorForm validatorForm, Object data) {
        if (data == null) {
            String message = validatorForm.getErrorMsg();
            return new ValidateEntity(ValidatorConstants.DEFAULT_ERROR_CODE, message, data,
                validatorForm.getParamName());
        }
        return null;
    }
}